package com.example.newfxdemo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.newfxdemo.entity.Emp;
import com.example.newfxdemo.service.IEmpService;
import com.example.newfxdemo.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xgz
 * @since 2023-03-07
 */
@RestController
@RequestMapping("/emp")
@Api("员工接口类")
public class EmpController {

    @Autowired
    private IEmpService iEmpService;

    @GetMapping("getEmpAll/{current}/{size}")
    @ApiOperation("分页查询")
    private Result findAll(@ApiParam(value = "当前页码",required = true)@PathVariable("current") Integer current
                        ,@ApiParam(value ="每页显示条数",required = true)@PathVariable("size") Integer size){
        Page<Emp> page = new Page(current,size);
        Page<Emp> page1 = iEmpService.findAll(page);
        return new Result(page1);
    }


    @DeleteMapping("{EMPNO}")
    @ApiOperation("删除")
    private Result delEmp(@ApiParam("根据EMPNO删除") @PathVariable("EMPNO") Integer empno){

        return new Result(iEmpService.removeById(empno));
    }
}

